package com.dkcrow.transaction.anno.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class UserDaoImpl{

	@Autowired SqlSession sqlSession;
	
	@SuppressWarnings("unchecked")
	public List<Map<String, Object>> selectUserCompare() {
		return sqlSession.selectList("USER.selectUser");
	}
	
	public void insertUser(String id, String name, int age) {
		Map<String,Object>param = new HashMap<String,Object>();
		param.put("id", id);
		param.put("name", name);
		param.put("age", age);
		sqlSession.insert("USER.insertUser",param);
	}
	
	public void updateUser(String id, String name, int age) {
		Map<String,Object>param = new HashMap<String,Object>();
		param.put("id", id);
		param.put("name", name);
		param.put("age", age);
		sqlSession.update("USER.updateUser",param);
	}
	
	public void deleteAllUser(){
		sqlSession.insert("USER.deleteAllUser");
	}
}
